package com.data.service.extension;

import com.google.common.collect.Maps;

import java.util.Map;

public class DataSourceSwitcher {

    public static Map<String, Datasource> DATA_SOURCE_CONFIG = Maps.newHashMap();

    static {
        Datasource tableInfo = new Datasource();

        tableInfo.setCode("information_schema");
        tableInfo.setTableInfoCode("information_schema");
        tableInfo.setType("MysqlDataSourceExtension");
        tableInfo.setBeanName("tableInfo");
        DATA_SOURCE_CONFIG.put(tableInfo.getCode(), tableInfo);

        Datasource dataInfo = new Datasource();

        dataInfo.setCode("data");
        dataInfo.setTableInfoCode("information_schema");
        dataInfo.setType("MysqlDataSourceExtension");
        dataInfo.setBeanName("master");
        DATA_SOURCE_CONFIG.put(dataInfo.getCode(), dataInfo);
    }

    public static Datasource getDataSource(String code) {
        return DATA_SOURCE_CONFIG.get(code);
    }
}
